import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        //2)数组的拷贝
        int[] arr = {1,2,3,4,5};
        int[] copy = Arrays.copyOf(arr, arr.length * 2);
        System.out.println(Arrays.toString(copy));

        //3)数组的拷贝
        int[] arr2 = {10,6,7,8,9};
        System.arraycopy(arr2, 0,copy, 5, 5);
        System.out.println(Arrays.toString(copy));
    }
    public static void main2(String[] args) {
        //1.数组的拷贝

        //错误，此方式不属于数组拷贝
//        int[] arr = {1,2,3,4,5};
//        int[] arr2 = arr;
//        System.out.println(Arrays.toString(arr2));

        //1)
        int[] arr3 = {1,3,4,5,6};
        int[] arr4 = new int[arr3.length];
        for (int i = 0; i < arr3.length; i++){
            arr4[i] = arr3[i];
        }
        String ret = Arrays.toString(arr4);
        System.out.println(ret);
    }
}